import Vue from 'vue'
import Vuex from 'vuex'

Vue.use(Vuex)

export default new Vuex.Store({
  state: {
    examQuestions: [], // 考试题目
    examDetail: [], // 考试详情
    wrongExam: [], // 错题库
  },
  mutations: {
    'SHOW_IMG_PREVIEW'(state, {
      context,
      imgs,
      index
    }) {
      context.$createImagePreview({
        imgs,
        'initial-index': index
      }).show()
    },
    'SET_EXAM_QUESTIONS'(state, questions) {
      state.examQuestions = questions
    },
    'SET_EXAM_DETAIL'(state, detail) {
      state.examDetail = detail
    },
    'SET_WRONG_EXAM'(state, exam) {
      state.wrongExam = exam
    },
    'DELETE_WRONG_QUESTION'(state, index) {
      state.wrongExam.splice(index, 1)
    }
  },
  actions: {

  }
})